<?php

namespace Wantuch\MailerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="campaigns")
 */
class Campaign
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $name;

    /**
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    protected $defaultSender;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    protected $defaultTemplate;
    
    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $createdAt;
    
    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    protected $updatedAt;
    
    /**
     * @ORM\OneToMany(targetEntity="Subscriber", mappedBy="campaign")
     **/
    private $subscribers;
    
    /**
     * @ORM\ManyToOne(targetEntity="Company", inversedBy="campaigns")
     * @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=true)
     **/
    private $company;
    
    
    /**
     * @ORM\OneToMany(targetEntity="Message", mappedBy="campaign")
     **/
    private $messages;
    
    /**
     * @ORM\Column(type="string", length=100,  nullable=true)
     */
    protected $token;
    
    
    
    public function __toString()
    {
        return (string) $this->getName()." | ".$this->getCompany();
    }

    
    
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->subscribers = new \Doctrine\Common\Collections\ArrayCollection();
        $this->messages = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Campaign
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set defaultSender
     *
     * @param string $defaultSender
     * @return Campaign
     */
    public function setDefaultSender($defaultSender)
    {
        $this->defaultSender = $defaultSender;

        return $this;
    }

    /**
     * Get defaultSender
     *
     * @return string 
     */
    public function getDefaultSender()
    {
        return $this->defaultSender;
    }

    /**
     * Set defaultTemplate
     *
     * @param string $defaultTemplate
     * @return Campaign
     */
    public function setDefaultTemplate($defaultTemplate)
    {
        $this->defaultTemplate = $defaultTemplate;

        return $this;
    }

    /**
     * Get defaultTemplate
     *
     * @return string 
     */
    public function getDefaultTemplate()
    {
        return $this->defaultTemplate;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return Campaign
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime 
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     * @return Campaign
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime 
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set token
     *
     * @param string $token
     * @return Campaign
     */
    public function setToken($token)
    {
        $this->token = $token;

        return $this;
    }

    /**
     * Get token
     *
     * @return string 
     */
    public function getToken()
    {
        return $this->token;
    }

    /**
     * Add subscribers
     *
     * @param \Wantuch\MailerBundle\Entity\Subscriber $subscribers
     * @return Campaign
     */
    public function addSubscriber(\Wantuch\MailerBundle\Entity\Subscriber $subscribers)
    {
        $this->subscribers[] = $subscribers;

        return $this;
    }

    /**
     * Remove subscribers
     *
     * @param \Wantuch\MailerBundle\Entity\Subscriber $subscribers
     */
    public function removeSubscriber(\Wantuch\MailerBundle\Entity\Subscriber $subscribers)
    {
        $this->subscribers->removeElement($subscribers);
    }

    /**
     * Get subscribers
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getSubscribers()
    {
        return $this->subscribers;
    }

    /**
     * Set company
     *
     * @param \Wantuch\MailerBundle\Entity\Company $company
     * @return Campaign
     */
    public function setCompany(\Wantuch\MailerBundle\Entity\Company $company = null)
    {
        $this->company = $company;

        return $this;
    }

    /**
     * Get company
     *
     * @return \Wantuch\MailerBundle\Entity\Company 
     */
    public function getCompany()
    {
        return $this->company;
    }

    /**
     * Add messages
     *
     * @param \Wantuch\MailerBundle\Entity\Message $messages
     * @return Campaign
     */
    public function addMessage(\Wantuch\MailerBundle\Entity\Message $messages)
    {
        $this->messages[] = $messages;

        return $this;
    }

    /**
     * Remove messages
     *
     * @param \Wantuch\MailerBundle\Entity\Message $messages
     */
    public function removeMessage(\Wantuch\MailerBundle\Entity\Message $messages)
    {
        $this->messages->removeElement($messages);
    }

    /**
     * Get messages
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getMessages()
    {
        return $this->messages;
    }
}
